package cards.controller;

import cards.dao.UserDao;
import cards.entity.CardActivity;
import cards.entity.User;
import cards.service.CardActivityService;
import cards.util.HostHolder;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import java.util.List;

@Controller
public class CardActivityController {
    @Autowired
    private UserDao userDao;
    @Autowired
    private HostHolder localHost;
    @Autowired
    private CardActivityService cardActivityService;

    @RequestMapping(path="/{usertype}/unattended", method= RequestMethod.GET)
    public String displayCardActivityPage2(@PathVariable String usertype, Model model) {
        String category = "unattended";
        User user=localHost.getUser();
        List<CardActivity> pageList=cardActivityService.findCardActivity(usertype);

        model.addAttribute("user", user);
        model.addAttribute("topics", pageList);
        model.addAttribute("header", "所有活动");
        model.addAttribute("userDao", userDao);
        return category;
    }
}
